package com.yyfax.pay.quartz.adapter.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.yyfax.pay.common.annotation.DepositQueryTaskType;
import com.yyfax.pay.common.enums.FuiouBusiTypeEnum;
import com.yyfax.pay.common.enums.FuiouDepositStateEnum;
import com.yyfax.pay.depository.domain.FuiouQueryTask;
import com.yyfax.pay.depository.domain.FuiouWithdraw;
import com.yyfax.pay.depository.service.inner.FuiouWithdrawService;
import com.yyfax.pay.quartz.adapter.DepositQueryHandlerAdapter;
import com.yyfax.pay.quartz.model.vo.TaskResultVO;

/**
 * 提现查询
 *
 * @author yejc
 * @date 2017-09-30
 * @since v1.0.0
 */
@Service
@DepositQueryTaskType(FuiouBusiTypeEnum.WITHDRAW_QUERY)
public class FuiouWithdrawQueryHandler implements DepositQueryHandlerAdapter {
	@Resource
	private FuiouWithdrawService fuiouWithdrawService;

	@Override
	public TaskResultVO handle(FuiouQueryTask task) throws Throwable {
		FuiouWithdraw withdraw = fuiouWithdrawService.withdrawQuery(task.getBusiId());
		if (FuiouDepositStateEnum.FAIL.isValue(withdraw.getState()) || FuiouDepositStateEnum.SUCCESS.isValue(withdraw.getState())) {
			return new TaskResultVO(true);
		}

		return new TaskResultVO(false);
	}
}
